package java115.Thread;
//实现 Runnable接口, 重写 run
public class Demo2 {
    private static class MyRunnable implements Runnable {
        @Override
        public void run() {
            for (int i = 0; i <5; i++) {
                System.out.println("执行MyRunnable线程");
                try {
                    Thread.sleep(1000);
                } catch ( InterruptedException e) {
                    e.printStackTrace();
                }
            }
            
        }
    }
    public static void main(String[] args) {
        MyRunnable r1 = new MyRunnable();
        Thread t1 = new Thread(r1);
        t1.start();
        for (int i = 0; i < 5; i++) {
            System.out.println("执行main线程");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }     
    }
}
